home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / ScrapColor 1.0 / Scrap Color Documentation next >
Text File  |  1996-06-14  |  13KB  |  161 lines

  1. Scrap Color Clipboard Format
  2. Released June, 1996 by Mark Womack and Patrick Bores
  3. Code Library written by Mark Womack
  4.  
  5. Introduction
  6.  
  7. Have you ever noticed that there isn't an effective way to transfer color information from one program to another without resorting to writing down the actual values of a color and then typing them back in where you want them?  It's annoying to say the least.  Especially if you want to move or keep track of a number of colors.  Also, if the information could be moved from one application to another, programs could work together better and in a more integrated fashion.
  8.  
  9. At least that's what we figured.  Mark is the author of ColorSieve, a popular freeware utility that helps C, Pascal, and HTML programmers look at and manipulate color information.  Patrick is the author of WebColor, a popular sharware application that helps HTML authors create web pages with custom colors defined for the background as well as the various types of links (as well as other neat features).  We felt that our programs could work together really well if they could communicate the color information back and forth.
  10.  
  11. So, we created the Scrap Color clipboard format and supporting code library.  We will be integrating this functionality into our programs, and we hope that others will do so as well.  With the supporting code library written, it is a snap to integrate and call.  Plus, we are placing the format and code library in the public domain.  It's free to use as you like with no copyrights or licensing fees.  You don't even have to mention it in your about box.
  12.  
  13. We hope that this format can become a standard to communicate color information between applications by using the clipboard.  That will only happen if people start to use it in their applications, both commercial and shareware.  So, please take a look at the rest of this document and the code library.  We hope that you can use it!
  14.  
  15. Clipboard Format
  16.  
  17. The format of the Scrap Color data was designed with more than just our applications in mind.  It is meant to be a more general solution for transfering color information.
  18.  
  19. The format supports the RGB, HSL, HSV, and CMY color models.  These are the color models currently supported by Apple's Color Picker manager.
  20.  
  21. The format also supports more than one color being saved into the format.  Also, the colors don't have to all be in one color model.  They can be mixed.  So, a program could place a whole row of colors into the clipboard, some of them being RGB and some of them being CMY or any other color model.
  22.  
  23. The following describes the Scrap Color format in detail.  It is described so that if you have to write your own code to deal with the format, you'll know what to look for.  However, we strongly urge you to use the code library that accompanied this read me.  It is a stable, tested reference that already supports the format.  Why re-writeit?
  24.  
  25. Here's a picture of what the ScrapColor format looks like:
  26.  
  27. --------------------
  28. | Version          |  unsigned short (2 bytes)
  29. --------------------
  30. | Number of Colors |  unsigned short (2 bytes)
  31. --------------------
  32. | Color 1          |  ScrapColorData (8 bytes)
  33. --------------------
  34. | Color 2          |  ScrapColorData (8 bytes)
  35. --------------------
  36.   ...
  37. (ScrapColorData is repeated for number of colors)
  38.  
  39. It is basically an array of ScrapColorData with a count as the first short so you know how many colors are stored in the clipboard.  The version info is used in case the format is changed in the future.  Old libraries will realize they can't read the new format, and old libraries will be able to convert the old structure.  It will only be incremented if the format actually changes.  A ScrapColorData structure looks like this:
  40.  
  41. --------------------
  42. | The Color's Model|  short          (2 bytes)
  43. --------------------
  44. | The Color's Data |  ColorData      (6 bytes)
  45. --------------------
  46.  
  47. This structure is basically a tag to let you know what model the following data is stored as.  The data is stored in a ColorData structure, and it looks like this:
  48.  
  49. --------------------
  50. | Value 1 of Color |  SmallFract    (2 bytes)
  51. --------------------
  52. | Value 2 of Color |  SmallFract    (2 bytes)
  53. --------------------
  54. | Value 3 of Color |  SmallFract    (2 bytes)
  55. --------------------
  56.  
  57. The SmallFract type is an unsigned short.  It is used by all the color structures defined in the Color Picker Manager.  The ColorData structure is a generic type that can store any values of the supported color models.  Since they are all the same size, it makes it very convienent.
  58.  
  59. Supporting Code Library
  60.  
  61. The code library is meant to buffer programmers from having to program the nitty-gritty details of the Scrap Color clipboard format.  It also provides a stable reference that everyone can use instead of  having to re-invent the wheel each time.
  62.  
  63. Currently, even though the Scrap Color format supports multiple colors, the library only defines routines to get and put single colors.  Going the next step and creating routines to get and put whole arrays of colors is fairly simple, in fact a future version of the library will have these routines.  But to meet time contraints we chose to release the library with single color routines.
  64.  
  65. The routines can be broken into three classes: Getting, Putting, Converting.  The Getting and Putting classes each have routines that support generic color data and routines that support specific color models.
  66.  
  67. Getting
  68.  
  69. pascal OSErr GetColorFromScrap(ColorData* colorData, short* colorModel);
  70.  
  71. GetColorFromScrap returns a ColorData structure and a color model descriptor.  This information is taken directly from the clipboard.  This routine makes no attempt to convert the data into any specific color model.
  72.  
  73. pascal OSErr GetRGBColorFromScrap(RGBColor* theColor);
  74.  
  75. GetRGBColorFromScrap does just what it says.  It returns the color data in the clipboard as an RGBColor.  If the color data is stored in a different format than RGB, a conversion is performed to change it into RGB format.
  76.  
  77. pascal OSErr GetHSLColorFromScrap(HSLColor* theColor);
  78.  
  79. GetHSLColorFromScrap does just what it says.  It returns the color data in the clipboard as an HSLColor.  If the color data is stored in a different format than HSL, a conversion is performed to change it into HSL format.
  80.  
  81. pascal OSErr GetHSVColorFromScrap(HSVColor* theColor);
  82.  
  83. GetHSVColorFromScrap does just what it says.  It returns the color data in the clipboard as an HSVColor.  If the color data is stored in a different format than HSV, a conversion is performed to change it into HSV format.
  84.  
  85. pascal OSErr GetCMYColorFromScrap(CMYColor* theColor);
  86.  
  87. GetCMYColorFromScrap does just what it says.  It returns the color data in the clipboard as an CMYColor.  If the color data is stored in a different format than CMY, a conversion is performed to change it into CMY format.
  88.  
  89. Putting
  90.  
  91. pascal OSErr PutColorIntoScrap(const ColorData* colorData, const short colorModel);
  92.  
  93. PutColorIntoScrap takes a ColorData structure and a color model descriptor and places them into the clipboard.  It does not call ZeroScrap(), so the Scrap Color data type will coexist with any other data types that are currently stored in the clipboard.  If you don't want any other types on the clipbord you must call ZeroScrap() yourself before calling PutColorIntoScrap().
  94.  
  95. pascal OSErr PutRGBColorIntoScrap(const RGBColor* theColor);
  96.  
  97. PutRGBColorIntoScrap takes an RGBColor places it into the clipboard.  It fills in the correct color model descriptor automatically.  It does not call ZeroScrap(), so the Scrap Color data type will coexist with any other data types that are currently stored in the clipboard.  If you don't want any other types on the clipboard you must call ZeroScrap() yourself before calling PutColorIntoScrap().
  98.  
  99. pascal OSErr PutHSLColorIntoScrap(const HSLColor* theColor);
  100.  
  101. PutHSLColorIntoScrap takes an HSLColor places it into the clipboard.  It fills in the correct color model descriptor automatically.  It does not call ZeroScrap(), so the Scrap Color data type will coexist with any other data types that are currently stored in the clipboard.  If you don't want any other types on the clipboard you must call ZeroScrap() yourself before calling PutColorIntoScrap().
  102.  
  103. pascal OSErr PutHSVColorIntoScrap(const HSVColor* theColor);
  104.  
  105. PutHSVColorIntoScrap takes an HSVColor places it into the clipboard.  It fills in the correct color model descriptor automatically.  It does not call ZeroScrap(), so the Scrap Color data type will coexist with any other data types that are currently stored in the clipboard.  If you don't want any other types on the clipboard you must call ZeroScrap() yourself before calling PutColorIntoScrap().
  106.  
  107. pascal OSErr PutCMYColorIntoScrap(const CMYColor* theColor);
  108.  
  109. PutCMYColorIntoScrap takes an CMYColor places it into the clipboard.  It fills in the correct color model descriptor automatically.  It does not call ZeroScrap(), so the Scrap Color data type will coexist with any other data types that are currently stored in the clipboard.  If you don't want any other types on the clipboard you must call ZeroScrap() yourself before calling PutColorIntoScrap().
  110.  
  111. Converting
  112.  
  113. pascal OSErr ConvertColor(const ColorData* oldColor, const short oldModel, ColorData* newColor, const short newModel);
  114.  
  115. ConvertColor is a convienent routine to convert color data from one color model to another.  This is the routine used by the library to perform conversions when needed.  Old color data is passed in with a color model descriptor indicating the model it is in and a color model descriptor describing the model you want it converted to.  The color data is returned in a different ColorData parameter.  Since the ColorData structure is the same size as the supported color structures, you can, if you want, coerce those structures to a ColorData pointer.  Also, you can pass the same pointer to the oldColor and newColor parameters to perform an in-place conversion.
  116.  
  117. Demo Application
  118.  
  119. The demo application that is shipped with the code library is a very simple example of how to use the code library.  It let's you put values from the color picker into clipboard.  It also watches the clipboard and when it senses that the clipboard has changed, it trys to get Scrap Color data from it.  If it succeeds, it displays the values it found in the color model the data was stored in.
  120.  
  121. Other Languages
  122.  
  123. Right now the code library is in C, but all the routines are Pascal compatible.  We would be more than happy to include a Pascal version of these routines in a future package, or even a Pascal compatible library file.  If there's a Pascal programmer out there that wants to do it and then send us the result, we'll give appropriate credit.  The more the merrier.
  124.  
  125. Miscellaneous
  126.  
  127. The values displayed are sometimes off, especially if you use the Apple Color Picker.  This has something to do with the display code, not the Scrap Color format or code library.  The exact values returned from the color picker are used when putting and getting data.
  128.  
  129. Disclaimer & License for use
  130.  
  131. The Scrap Color format and the supporting code library are placed in the public domain for the benefit of all.  Again, we hope that this format will become a standard for communicating color information between applications via the clipboard.  You are free to use it as you wish.  We only ask that if you change the format, please change the data type from 'sCLR' to something new so there is no confusion.
  132.  
  133. This software is offered 'as is'.  The authors are not liable for any damages resulting from usage of this software,  bugs and defects in this software, or any other problems you might encounter.  By including it in any software you create, you accept these terms.
  134.  
  135. Contacts & Updates
  136.  
  137. There is an email address, mailing list, and web page for Scrap Color.
  138.  
  139. The email address is <ScrapColor@aol.com>.  If you have any questions, find a program you wish used Scrap Color, or write a program that uses Scrap Color, please drop us a line!
  140.  
  141. We will be maintaining a mailing list of people interested in updates and developments regarding Scrap Color.  If you'd like to be included on this mailing list, please sent a message to the Scrap Color address.
  142.  
  143. The web page for Scrap Color is <http://members.aol.com/scrapcolor/scrapcolor.html>.  From here you will be able to learn about and download the latest versions of the Scrap Color format and source library.
  144.  
  145. If you use Scrap Color in your application, let us know at the Scrap Color email address.  Give us a link and we'll add it to the Scrap Color web page!
  146.  
  147. Programs that use Scrap Color
  148.  
  149. There are currently only two programs that support or will support the Scrap Color format.  We'd really like to see this list grow!
  150.  
  151. ColorSieve 1.2 - Not yet released, current version 1.1.
  152. Author: Mark Womack
  153. Email: markwomack@aol.com
  154. WWW: http://members.aol.com/markwomack/colorsieve.html
  155.  
  156. WebColor 2.0.2 - Not yet released, current version 2.0.
  157. Author: Patrick Bores
  158. Email: WColorInfo@aol.com
  159. WWW: http://users.aol.com/wcolorinfo
  160.  
  161.